import java.util.Scanner;

public class 二分查找 {
    //给定一个有序整型数组, 实现二分查找;
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 8, 9};
        int left = 0;
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();//键入要查找的值；
        int right = array.length - 1;
        while (left <= right) {
            int maddion = (right + left) / 2;
            if (k == array[maddion]) {
                System.out.println("要查找的z值" + k + "找到了");
                break;
            }
            if (k < array[maddion]) {
                right = maddion - 1;
            }
            if (k > array[maddion]) {
                left = maddion + 1;
            }
        }
        if (left > right) {
            System.out.println("该整形数组中没有要查找的数");
        }
    }
}
